<?php
$file=fopen("playlist.txt","r");
$array=array();
$array=unserialize(fread($file,filesize("playlist.txt")));
fclose($file);
	if (isset($_POST["link"])){
	$array[]=substr($_POST["link"], -11);
	$file=fopen("playlist.txt","w+");
	fwrite($file,serialize($array));
	fclose($file);
	
	
}
	if (isset($_GET["action"])){
	
	$nextID=array_shift($array);
	echo $nextID;
	$file=fopen("playlist.txt","w+");
	fwrite($file,serialize($array));
	fclose($file);
	
	$lastIndex++;
}
?>

